// homepage.h
#ifndef HOMEPAGE_H
#define HOMEPAGE_H

#include <QtWidgets>
#include "my_car.h"
#include "temperature_curve.h"
#include "parking_surveillance.h"
#include "setwig.h"
#include "search.h"  // 添加这行包含Search头文件
#include "hong.h"  // 添加这行包含背景图片宏

namespace Ui {
class HomePage;
}

class HomePage : public QWidget
{
    Q_OBJECT

public:
    explicit HomePage(QWidget *parent = 0);
    ~HomePage();

protected:
    void paintEvent(QPaintEvent *event) override;  // 添加重写paintEvent
    void resizeEvent(QResizeEvent *event) override;  // 新增：重写resizeEvent

private slots:
    void on_pushButton_clicked();
    void onDataReceived(const QByteArray &msg);
    void onModeChanged(int mode);  // 新增：模式改变槽函数
    void onDeviceOffline();        // 新增：设备离线处理

private:
    Ui::HomePage *ui;
    My_Car *myCar;
    Temperature_Curve *tempCurve;
    Parking_Surveillance *parkingSurveillance;
    SetWig *setWig;
    Search *search;  // 添加Search界面指针

    void sendStatusRequest();
    void sendRefreshRequest();  // 新增：发送刷新请求
    void sendModeRequest(int mode);  // 新增：发送模式请求
    QPixmap backgroundPixmap;  // 添加背景图片成员变量

    // 新增：设备离线显示相关
    QLabel *deviceOfflineLabel;
    void setupDeviceOfflineLabel();
    void showDeviceOfflineWarning();
    void hideDeviceOfflineWarning();
};

#endif // HOMEPAGE_H
